/*******************************************************************************
Replication Materials for Blau, Kahn, Brummund, Cook, and Larson-Koester "Is 
There Still Son Preference in the United States?"

Table 3

Date Modified: 10/21/2019

*******************************************************************************/




*-------------------------------------------------------------------------------
                                   *LOAD DATA
*-------------------------------------------------------------------------------
use "$acs\acs_data" if native == 0,clear


*-------------------------------------------------------------------------------
                               *RESTRICT SAMPLE
*-------------------------------------------------------------------------------
keep if nonusbirth == 0 & multi_sample != 1 & mult == 0 & oldc <=12 & ///
	inrange(age,18,40)==1 & nchild18>=1
drop if citizen==1 | marst == 5


*Label Variables
label var igenfert "Total Fertility"
label var ligengdp "Log of GDP"
label var igenscore "Equity Index"
label var chld1 "First Child Girl"
label var igenlfp "Labor Force Part."
label var igensr "Sex Ratio at Birth"

label var girl_lfp "Girl*Labor Force Part."
label var girl_sr "Girl*Sex Ratio at Birth"
label var girl_ggi "Girl*Equity Index"




*-------------------------------------------------------------------------------
                       *REGRESSIONS, PROB LIVING WITHOUT A FATHER
*-------------------------------------------------------------------------------	
local wgt "perwtnorm"	
local controls "lths scol cold" //leave out: hsdi
local controls "`controls' i.genrace i.region i.year age age2 age3 `allvars'"
local controls "`controls' yrsusa1 yrsusa2"

// EQUITY
reg femhdalt `controls' igenfert ligengdp igenscore chld1 girl_ggi [aw=`wgt'],  cluster(bpldc)
sum femhdalt if igenscore != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_3_extended", replace excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenscore chld1 girl_ggi) ctitle(No Dad) label nocons nor2 ///
	title("Table 3 on the Extended Sample")

// LFPR
reg femhdalt `controls' igenfert ligengdp igenlfp chld1 girl_lfp [aw=`wgt'],  cluster(bpldc)
sum femhdalt if igenlfp != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_3_extended", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp chld1 girl_lfp) ctitle(No Dad) label nocons nor2

// LFPR & SEX RATIO AT BIRTH
reg femhdalt `controls' igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr [aw=`wgt'],  cluster(bpldc)
sum femhdalt if igenlfp != . & igensr != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_3_extended", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr) ctitle(No Dad) label nocons nor2

*-------------------------------------------------------------------------------
                              *REGRESSIONS, FERTILITY
*-------------------------------------------------------------------------------	
local wgt "perwtnorm"	
local controls "lths scol cold sp_lths sp_scol sp_cold" //leave out: hsdi
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3 `allvars'"
local controls "`controls' yrsusa1 yrsusa2 sp_yrsusa1 sp_yrsusa2 sp_imm"

// SAMPLE
keep if father_sample != 1 & female == 1  & marst == 1


// EQUITY
reg nchild `controls' igenfert ligengdp igenscore chld1 girl_ggi [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenscore != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_3_extended", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenscore chld1 girl_ggi) ctitle(Fertility) label nocons nor2

// LFPR
reg nchild `controls' igenfert ligengdp igenlfp chld1 girl_lfp [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenlfp != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_3_extended", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp chld1 girl_lfp) ctitle(Fertility) label nocons nor2

// LFPR & SEX RATIO AT BIRTH
reg nchild `controls' igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr [aw=`wgt'],  cluster(bpldc)
sum nchild if marst == 1 & igenlfp != . & igensr != . [aw=`wgt']
local mean: display %5.4f r(mean)
outreg2 using "$routput\Table_3_extended", append excel dec(4) addtext(Dep. Var. Mean, `mean') keep(igenfert ligengdp igenlfp igensr chld1 girl_lfp girl_sr) ctitle(Fertility) label nocons nor2 sortvar(igenfert ligengdp igenlfp igensr igenscore chld1 girl_lfp girl_sr girl_ggi)
 
